package inputStream;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class t3anli {
    public static void main(String[] args) throws FileNotFoundException {
        readAndWriteFn("D:\\study\\999.java拓展\\自己敲代码-git\\javaBase\\homeExtendDay13\\src\\main\\java\\inputStream\\嘿嘿.png","D:\\study\\999.java拓展\\自己敲代码-git\\javaBase\\homeExtendDay13\\src\\main\\java\\inputStream\\res\\嘿嘿.png");

    }

    private static void readAndWriteFn(String inputPath,String outputPath) {
        if((inputPath.isEmpty() || outputPath.isEmpty()))return; // 任意一个为空
        try(FileInputStream fis =   new FileInputStream(inputPath);){
            FileOutputStream fos =   new FileOutputStream(outputPath,true);
            int flag = 0;
            byte[] byteArr = new byte[2];
            while (flag !=-1){
                int len = flag =  fis.read(byteArr);
                if(len != -1){
                    fos.write(byteArr,0,len);
                }
            }
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

}
